import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PoInfoVO, PoInfoForm, PoInfoQuery } from '@/api/wms/fg/poInfo/types';
import { FetchOrderParam } from '@/api/types';

/**
 * 查询采购订单分页列表
 * @param query
 * @returns {*}
 */
export const pagePoInfo = (query?: PoInfoQuery): AxiosPromise<PoInfoVO[]> => {
  return request({
    url: '/wms/fg/poInfo/page',
    method: 'get',
    params: query
  });
};
/**
 * 查询采购订单列表
 * @param query
 * @returns {*}
 */
export const listPoInfo = (query?: PoInfoQuery): AxiosPromise<PoInfoVO[]> => {
  return request({
    url: '/wms/fg/poInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询采购订单详细
 * @param id
 */
export const getPoInfo = (id: string | number): AxiosPromise<PoInfoVO> => {
  return request({
    url: '/wms/fg/poInfo/' + id,
    method: 'get'
  });
};

/**
 * 下载采购订单
 * @param data
 */
export const fetchPoInfo = (data: FetchOrderParam) => {
  return request({
    url: '/wms/fg/fg/poInfo/fetch',
    method: 'post',
    data: data
  });
};

/**
 * 新增PO单据主表
 * @param data
 */
export const addPoInfo = (data: PoInfoForm) => {
  return request({
    url: '/wms/fg/poInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改采购订单
 * @param data
 */
export const updatePoInfo = (data: PoInfoForm) => {
  return request({
    url: '/wms/fg/poInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除采购订单
 * @param id
 */
export const delPoInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/wms/fg/poInfo/' + id,
    method: 'delete'
  });
};
